home *** CD-ROM | disk | FTP | other *** search
/ Suzy B Software 2 / Suzy B Software CD-ROM 2 (1994).iso / bootup / boot_a2m / darklord / globes2.c < prev    next >
C/C++ Source or Header  |  1995-05-02  |  2KB  |  85 lines

  1. /* 1st Darklord module */
  2.  
  3. #include "vdi.h"
  4. #include "stdlib.h"
  5. #include "mod_head.h"
  6.  
  7. #define OFFSET 12
  8. #define START 0
  9. #define STOP 3600
  10.  
  11. #ifndef TRUE
  12. #define TRUE 1
  13. #define FALSE 0
  14. #endif
  15.  
  16. int calc_num(int, int);
  17.  
  18. int main(DKL_INFO *dark_pars)
  19. {
  20. short handle, xres, yres;
  21. short pxy[4];
  22. int *exit_flag;
  23. int max_colours;
  24. short centrex, centrey, perm_radius1, perm_radius2;
  25. short temp_radius1, temp_radius2, colour;
  26. int min_rad, max_rad, spheres;
  27.  
  28.     xres=dark_pars->dk_xres;
  29.     yres=dark_pars->dk_yres;
  30.     handle=dark_pars->dk_handle;
  31.     exit_flag=dark_pars->dklord_flag;
  32.     max_colours=dark_pars->dk_pens;
  33.     min_rad=dark_pars->dk_start1;
  34.     max_rad=dark_pars->dk_start2;
  35.     spheres=dark_pars->dk_flag1;
  36.  
  37.     pxy[0]=0;
  38.     pxy[1]=0;
  39.     pxy[2]=xres;
  40.     pxy[3]=yres;
  41.     vs_clip(handle, TRUE, pxy);        /* set clip rectangle */
  42.  
  43.     while(*exit_flag) {
  44.         perm_radius1=(short)calc_num(min_rad, max_rad);
  45.         perm_radius1=(perm_radius1/5)*5;
  46.         if(spheres==1) perm_radius2=perm_radius1;
  47.         else if(spheres==2) {
  48.             perm_radius2=(short)calc_num(min_rad,max_rad);
  49.             perm_radius1=(perm_radius1/5)*5;
  50.         }
  51.  
  52.         centrex=(short)calc_num(OFFSET, xres-OFFSET);
  53.         centrey=(short)calc_num(OFFSET, yres-OFFSET);        
  54.         colour=(short)calc_num(1, max_colours);    /* choose a colour */
  55.         vsl_color(handle, colour);
  56.         vsf_interior(handle, FIS_HOLLOW);    /* hollow fill */
  57.         vsf_color(handle, colour);            /* chosen colour */
  58.         vsf_perimeter(handle, TRUE);        /* perimeter on */
  59.  
  60.         v_ellipse(handle, centrex, centrey, perm_radius1, perm_radius2);
  61.         temp_radius1=perm_radius2-5;
  62.         temp_radius2=perm_radius1-5;
  63.         v_ellarc(handle, centrex, centrey, perm_radius1, perm_radius2, START, STOP);
  64.  
  65.         while(TRUE){
  66.             if(temp_radius1>=0) v_ellarc(handle, centrex, centrey, perm_radius1, temp_radius1, START, STOP);
  67.             if(temp_radius2>=0) v_ellarc(handle, centrex, centrey, temp_radius2, perm_radius2, START, STOP);
  68.             temp_radius1-=5;
  69.             temp_radius2-=5;
  70.             if(temp_radius1<0 && temp_radius2<0) break;
  71.         }
  72.     }
  73.     return 0;
  74. }
  75. /* -------------------------------------------------------------------- */
  76. int calc_num(int min, int max)
  77. {
  78. int diff;
  79.  
  80.     diff=max-min;
  81.     if(!diff) diff=1;    /* avoid divide-by-zero exception */
  82.     return ((rand()%diff)+min);
  83. }
  84. /* -------------------------------------------------------------------- */
  85.